package com.lpf.servlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/hello") // 拦截 /hello 路径
public class HelloServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println(Thread.currentThread() + " start...");

        try {
            sayHello();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        response.getWriter().write("hello...");
        System.out.println(Thread.currentThread() + " end...");
    }

    public void sayHello() throws InterruptedException {
        System.out.println(Thread.currentThread() + " processing...");
        Thread.sleep(3000);
    }

}
